<?php

namespace addons\shopro\controller;

use app\admin\model\Information as InformationModel;

class Information extends Common
{

    protected $noNeedLogin = ['init', 'pageSync', 'page', 'feedback', 'detail', 'list'];
    protected $noNeedRight = ['*'];

    /**
     * 资讯列表
     * */
    public function list()
    {
        $list_rows = $this->request->param('list_rows', 10);
        $list=InformationModel::field("id,image,blurb")
            ->order('weigh desc,createtime desc')
            ->paginate($list_rows);
        $this->success("", $list);
    }
    /**
     * 资讯详情
     * */
    public function detail()
    {
        if(!$this->request->param('id')) $this->error("id为空");
        $id = $this->request->param('id');
        $detail=InformationModel::field("id,name,image,blurb,content,createtime")->find($id);
        if(empty($detail)) $this->error("资讯不存在");
        $this->success("", $detail);
    }
}
